package com.eastseeway.radioproject.entities;

import android.util.Log;

import androidx.annotation.Keep;

import com.eastseeway.radioproject.utils.ByteUtil;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import struct.StructClass;
import struct.StructField;
@Keep
@StructClass
public class BeanToEnergyBoard {

    @StructField(order = 0)
    private byte boardcommand;
    @StructField(order = 1)
    private byte cnt_pusle;                    // 断续脉冲数
    @StructField(order = 2)
    private byte continuous_duration;          // 连续输出时长（毫秒）
    @StructField(order = 3)
    private byte  version;
    @StructField(order = 4)
    private byte version1;     // 断续输出时长（毫秒）
    @StructField(order = 5)
    private byte numofpackage;
    @StructField(order = 6)
    private int crc;    // 休闲时长（毫秒）
    @StructField(order = 7)
    private byte  nack;
    @StructField(order = 8)
    private byte[]  place_holder = new byte[53];                 // 能量等级

    public byte getCommand() {
        return boardcommand;
    }

    public void setBoardcommand(byte boardcommand) {
        this.boardcommand = boardcommand;
    }

    //    待机模式 开始接收
    public void setBoardcommand(byte freq,boolean is_intermittent,boolean is_standby_state,boolean isCalibration) {
        int union = 0;
        if (freq == 2){
            union = 1 << 2 | union;
        }
        if (is_intermittent){
            union = 1 << 3 | union;
        }
        if (!is_standby_state){
            union = 1 << 4 | union;
        }
        if (isCalibration){
            union = 1 << 5 | union;
        }
//        Log.e("12121","13131: "+Integer.toBinaryString(union));
        this.boardcommand = (byte) union;
    }

    public byte getBoardcommand() {
        return boardcommand;
    }

    public byte getContinuous_duration() {
        return continuous_duration;
    }

    public void setContinuous_duration(byte continuous_duration) {
        this.continuous_duration = continuous_duration;
    }


    public BeanToEnergyBoard() {
    }

    public byte getCnt_pusle() {
        return cnt_pusle;
    }

    public void setCnt_pusle(byte cnt_pusle) {
        this.cnt_pusle = cnt_pusle;
    }


    public byte getVersion() {
        return version;
    }

    public void setVersion(byte version) {
        this.version = version;
    }

    public byte getVersion1() {
        return version1;
    }

    public void setVersion1(byte version1) {
        this.version1 = version1;
    }

    public byte getNumofpackage() {
        return numofpackage;
    }

    public void setNumofpackage(byte numofpackage) {
        this.numofpackage = numofpackage;
    }

    public int getCrc() {
        return crc;
    }

    public void setCrc(int crc) {
        this.crc = crc;
    }

    public byte getNack() {
        return nack;
    }

    public void setNack(byte nack) {
        this.nack = nack;
    }

    public byte[] getPlace_holder() {
        return place_holder;
    }

    public void setPlace_holder(byte[] place_holder) {
        this.place_holder = place_holder;
    }
}
